package com.sugon.stream;

import com.sugon.entity.Employees;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;


public class TestStream_endOperation {

    public static void main(String[] args) {
        List<Employees> list = Employees.createEmployee();

        long size = list.stream().count();
        System.out.println("集合数量"+size);
        ArrayList<Object> students = new ArrayList<>();
        //Optional<Object> first = students.stream().findFirst();
        //System.out.println(first.get());
        Optional<Employees> o = list.stream().findFirst();
        //System.out.println(o.get());

        Optional<Employees> o2 = list.stream().findAny();
		/*while (true){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println(o2.get());
		}*/


        boolean b1 = list.stream().allMatch(e -> e.getAge() > 1);
        boolean b2 = list.stream().anyMatch(e -> e.getAge() > 18);
        boolean b3 = list.stream().noneMatch(e -> e.getAge() < 20);
        System.out.println(b1);
        System.out.println(b2);
        System.out.println(b3);

        //	list.stream().forEach(System.out::println);

    }
}




